//
//  PerfectContentTwoView.m
//  SHHCPhone
//
//  Created by sheng long on 14-6-18.
//  Copyright (c) 2014年 sheng long. All rights reserved.
//

#import "PerfectContentTwoView.h"

@implementation PerfectContentTwoView

@synthesize selected;

-(void)setContent:(NSString*)title
{
    UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectZero];
    [label1 setText:title];
    [label1 setTextColor:GET_COLOR(@"a3a3a3")];
    [label1 setBackgroundColor:[UIColor clearColor]];
    [label1 setFont:[UIFont boldSystemFontOfSize:14]];
    [label1 sizeToFit];
//    [label1 setTextAlignment:NSTextAlignmentCenter];
    [label1 setCenter:CGPointMake(label1.frame.size.width/2, self.frame.size.height/2)];
    [self addSubview:label1];

    UIImageView *image1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"完善资料页-标签左.png"]];
    [image1 sizeToFit];
    [image1 setTag:1];
//    [image1 setCenter:CGPointMake(label1.frame.size.width+label1.frame.origin.x+17+image1.frame.size.width/2, label1.center.y)];
    [image1 setCenter:CGPointMake(self.frame.size.width-image1.frame.size.width/2*3, label1.center.y)];
    [self addSubview:image1];
    
    UIImageView *image2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"完善资料页-标签右.png"]];
    [image2 sizeToFit];
    [image2 setTag:2];
    [image2 setCenter:CGPointMake(image1.frame.size.width+image1.frame.origin.x+image2.frame.size.width/2, image1.center.y)];
    [self addSubview:image2];
    
    UILabel *label2 = [[UILabel alloc] init];
    [label2 setText:@"是"];
    [label2 setTextColor:GET_COLOR(@"a3a3a3")];
    [label2 setBackgroundColor:[UIColor clearColor]];
    [label2 setFont:[UIFont boldSystemFontOfSize:14]];
    [label2 sizeToFit];
    [label2 setTag:3];
    [label2 setCenter:image1.center];
    [self addSubview:label2];
    
    UILabel *label3 = [[UILabel alloc] init];
    [label3 setText:@"否"];
    [label3 setTextColor:GET_COLOR(@"a3a3a3")];
    [label3 setBackgroundColor:[UIColor clearColor]];
    [label3 setFont:[UIFont boldSystemFontOfSize:14]];
    [label3 sizeToFit];
    [label3 setTag:4];
    [label3 setCenter:image2.center];
    [self addSubview:label3];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setFrame:CGRectMake(image1.frame.origin.x, image1.frame.origin.y, image1.frame.size.width+image2.frame.size.width, MAX(image1.frame.size.height, image2.frame.size.height))];
    [self addSubview:button];
    [button addTarget:self action:@selector(butt:) forControlEvents:UIControlEventTouchDown];
}

-(void)butt:(UIButton*)button
{
    self.selected = !selected;
}

-(void)setSelected:(BOOL)select
{
    selected = select;
    
    UIImageView *image1 = (UIImageView*)[self viewWithTag:1];
    UIImageView *image2 = (UIImageView*)[self viewWithTag:2];
    UILabel *label1 = (UILabel*)[self viewWithTag:3];
    UILabel *label2 = (UILabel*)[self viewWithTag:4];

    if (selected) {
        [image1 setImage:[UIImage imageNamed:@"完善资料页-标签左-选中.png"]];
        [image2 setImage:[UIImage imageNamed:@"完善资料页-标签右.png"]];
        [label1 setTextColor:[UIColor whiteColor]];
        [label2 setTextColor:GET_COLOR(@"fed2e1")];
    }else{
        [image1 setImage:[UIImage imageNamed:@"完善资料页-标签左.png"]];
        [image2 setImage:[UIImage imageNamed:@"完善资料页-标签右-选中.png"]];
        [label1 setTextColor:GET_COLOR(@"fed2e1")];
        [label2 setTextColor:[UIColor whiteColor]];
    }
}

@end
